package gui.Principal;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JPanel;
import javax.swing.border.TitledBorder;

import java.awt.SystemColor;
import javax.swing.JButton;
import javax.swing.JTextField;

import System.MainControl;

import java.awt.Color;
import java.awt.Font;
import java.awt.Dimension;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class PrincipalMainPanel extends JPanel implements ActionListener {

	private static final long serialVersionUID = 3498150461604139775L;
	private JTextField textField;
	private JTextField txtWelcome;
	private JButton btnNewButton;
	private JButton btnGetSystemInformation;
	private JButton btnRequestsForChanging;
	/**
	 * Create the panel.
	 */
	public PrincipalMainPanel() {
		super();
		setBackground(SystemColor.activeCaption);
		initialize();
	}

	private void initialize() {
		setBorder(new TitledBorder(null, "Principal Main Panel", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		setBackground(SystemColor.activeCaption);
		setBounds(100, 100, 622, 340);
		setLayout(null);
		
		btnNewButton = new JButton("Get Statistics Information");
		btnNewButton.setFont(new Font("Microsoft New Tai Lue", Font.BOLD, 14));
		btnNewButton.setBounds(101, 96, 272, 23);
		btnNewButton.addActionListener(this);
		add(btnNewButton);
		
		
		DateFormat dateFormat = new SimpleDateFormat("EEE, MMM d, ''yy",Locale.US);
		Date date = new Date();
		txtWelcome = new JTextField();
		txtWelcome.setEditable(false);
		txtWelcome.setFont(new Font("Tahoma", Font.BOLD, 12));
		txtWelcome.setText("| Welcome "+ MainControl.currentUser.getFirstName() + " | -- | Date: " + dateFormat.format(date) + " |");
		txtWelcome.setBackground(new Color(100, 149, 237));
		txtWelcome.setBounds(98, 23, 330, 28);
		
		add(txtWelcome);
		
		JButton button_2 = new JButton("LogOut");
		button_2.setSize(new Dimension(81, 40));
		button_2.setFont(new Font("Microsoft New Tai Lue", Font.BOLD, 15));
		button_2.setBounds(351, 263, 103, 31);
		add(button_2);
		
		btnGetSystemInformation = new JButton("Get System Information");
		btnGetSystemInformation.setFont(new Font("Microsoft New Tai Lue", Font.BOLD, 14));
		btnGetSystemInformation.setBounds(101, 159, 272, 23);
		btnGetSystemInformation.addActionListener(this);
		add(btnGetSystemInformation);
		
		btnRequestsForChanging = new JButton("Requests for Changing Exam Time");
		btnRequestsForChanging.setFont(new Font("Microsoft New Tai Lue", Font.BOLD, 14));
		btnRequestsForChanging.addActionListener(this);
		btnRequestsForChanging.setBounds(101, 213, 272, 23);
		add(btnRequestsForChanging);
		

	}
	
	@Override			
	public void actionPerformed(ActionEvent e) 
	{
		if(e.getSource()==btnNewButton)
			MainControl.setPrincipalGUI(1);
		if(e.getSource()==btnGetSystemInformation)
			MainControl.setPrincipalGUI(2);
		if(e.getSource()==btnRequestsForChanging)
			MainControl.setPrincipalGUI(3);	
	};
}
